package cn.lf.controller;

import cn.lf.dto.shop.ShopReqDTO;
import cn.lf.service.ShopInfoService;
import cn.lf.utils.ResponseModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 店铺信息表(ShopInfo)表控制层
 *
 * @author makejava
 * @since 2024-04-07 21:57:49
 */
@RestController
@RequestMapping("/shopInfo")
@Api(tags = "店铺信息相关接口")
public class ShopInfoController {
    /**
     * 服务对象
     */
    @Autowired
    private ShopInfoService shopInfoService;

    /**
     * 分页查询
     *
     * @param reqDTO 筛选条件
     * @return 查询结果
     */
    @PostMapping("/queryByPage")
    @ApiOperation("分页查询")
    public ResponseModel queryByPage(@RequestBody ShopReqDTO reqDTO) {
        return ResponseModel.buildSuccessResult("获取成功！", shopInfoService.queryByPage(reqDTO));
    }


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/queryById")
    @ApiOperation("通过主键查询单条数据")
    public ResponseModel queryById(@RequestParam("id") String id) {
        return ResponseModel.buildSuccessResult("获取成功！", shopInfoService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param reqDTO 实体
     * @return 新增结果
     */
    @PostMapping("/addOrUpdate")
    @ApiOperation("新增数据")
    public ResponseModel addOrUpdate(@RequestBody ShopReqDTO reqDTO) {
        return ResponseModel.buildSuccessResult("成功！", shopInfoService.addOrUpdate(reqDTO));
    }


    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/deleteById")
    @ApiOperation("删除数据")
    public ResponseModel deleteById(@RequestParam String id) {
        return ResponseModel.buildSuccessResult("成功！", shopInfoService.deleteById(id));
    }

}

